﻿using System;
using Castle.DynamicProxy;
using Newtonsoft.Json;

namespace netCoreStudy.Aop
{
	/// <summary>
	/// 自己定义 的 aop 
	/// </summary>
	public class CustomAutofacAop : IInterceptor
	{
		public void Intercept(IInvocation invocation)
		{
			Console.WriteLine($"当前方法{invocation.Method}");
			Console.WriteLine($"当前controller方法{invocation.MethodInvocationTarget}");
			object[] invocationArguments = invocation.Arguments;
			Console.WriteLine($"当前参数{string.Join(",", invocationArguments)}");
			object invocationReturnValue = invocation.ReturnValue;
			Console.WriteLine($"当前返回值{JsonConvert.SerializeObject(invocationReturnValue)}");
			invocation.Proceed(); // 继续执行
			Console.WriteLine($"方法执行完成!");
		}
	}
}